package com.jingtai.platform.controller.supply;

import com.jingtai.core.entity.BaseEntity;
import com.jingtai.core.entity.supply.SupplyInfo;
import com.jingtai.platform.service.supply.SupplyInfoService;
import com.jingtai.platform.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.jingtai.validate.swagger.CApiParam;

/**
 * 供应商
 *
 * @author sunlaiqian
 * @date 2020-12-02 18:31:31
 */
@Validated
@RestController
@RequestMapping("/platform/supplyinfo")
@Api(tags = "供应商")
public class SupplyInfoController{

    @Autowired
    private SupplyInfoService supplyInfoService;


    @ApiOperation("供应商列表查询")
    @GetMapping("/list")
    public ResultUtil aopSupplyInfoList(@CApiParam(name = "page",value = "页数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("page") Integer page,
                              @CApiParam(name = "limit",value = "每页个数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("limit") Integer limit,
                              @CApiParam(name = "conditions",value = "查询条件",required = false) @RequestParam("conditions") String conditions){
        return supplyInfoService.SupplyInfolist(page, limit, conditions);
    }

    @ApiOperation("供应商下拉查询")
    @GetMapping("/select")
    public ResultUtil aopSupplyInfoSelect(){
        return supplyInfoService.supplyInfoSelect();
    }


    @ApiOperation("根据ID查询supplyInfo实体")
    @GetMapping("/getSupplyInfoById")
    public ResultUtil GetSupplyInfoById(@CApiParam(name = "id",value = "supplyInfo实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return supplyInfoService.getSupplyInfoById(id);
    }


    @ApiOperation("新增supplyInfo实体")
    @PostMapping("/add")
    @ApiOperationSupport(ignoreParameters = {"supplyInfo.id","supplyInfo.createTime","supplyInfo.updateTime","supplyInfo.deleteFlag"})
    public ResultUtil aopAddSupplyInfo(@RequestBody @Validated({BaseEntity.Create.class}) SupplyInfo supplyInfo){
        return supplyInfoService.addSupplyInfo(supplyInfo);
    }

    @ApiOperation("编辑supplyInfo实体")
    @PostMapping("/edit")
    @ApiOperationSupport(ignoreParameters = {"supplyInfo.createTime","supplyInfo.updateTime","supplyInfo.deleteFlag"})
    public ResultUtil aopEditSupplyInfo(@RequestBody @Validated({BaseEntity.Update.class}) SupplyInfo supplyInfo){
        return supplyInfoService.editSupplyInfo(supplyInfo);
    }

    @ApiOperation("根据ID删除supplyInfo实体")
    @GetMapping("/delSupplyInfoById")
    public ResultUtil aopDelSupplyInfoById(@CApiParam(name = "id",value = "supplyInfo实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return supplyInfoService.delSupplyInfoById(id);
    }

}






